<!-- 新增基础 -->

<template>
  <div>
    <EasyRow col3>
      <FormInput label="预案名称" bind="emergencyPlanName" :max="20" third2 required />
      <FormSelect
        label="预案类型"
        bind="emergencyPlanTypeId, emergencyPlanTypeName, emergencyPlanTypeCode"
        :dict="CORE.DICT.preplan_type"
        required
      />
    </EasyRow>

    <FormTextarea label="预案描述" bind="emergencyPlanDesc" :max="100" required />

    <FormSelectMulti label="应急小组" bind="groupId" :dict="group_selectDict" required @change="changeGroup" />
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'AddBase',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb(), CORE.mixSelect('group', 'group_')],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换小组
     */
    changeGroup(idList) {
      this.one.emergencyPlanGroupDto = idList.map((id) => {
        const matched = this.group_select.find((item) => item.id === id)
        return { ...matched, emergencyGroupId: matched.id }
      })
    },
  },
}
</script>
